package com.wu.llpsw.effect.potion;

import net.minecraft.nbt.CompoundTag;
import net.minecraft.world.item.Item;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.alchemy.Potion;
import net.minecraft.world.item.alchemy.PotionUtils;
import net.minecraftforge.common.brewing.IBrewingRecipe;
//通用配方模板
public class recipe implements IBrewingRecipe {
    private final Potion input;
    private final Item ingredient;
    private final Potion output;

    public recipe(Potion input,Item item,Potion output){
        this.input=input;
        this.output=output;
        this.ingredient=item;
    }
    @Override
    public boolean isInput(ItemStack itemStack) {
        return PotionUtils.getPotion(itemStack)==this.input;
    }

    @Override
    public boolean isIngredient(ItemStack itemStack) {
        return itemStack.getItem()==this.ingredient;
    }

    @Override
    public ItemStack getOutput(ItemStack input, ItemStack ingredient) {
        if(!this.isInput(input)||!this.isIngredient(ingredient)){
            return  ItemStack.EMPTY;
        }
        ItemStack itemStack=new ItemStack(input.getItem());
        itemStack.setTag(new CompoundTag());
        PotionUtils.setPotion(itemStack,this.output);
        return itemStack;
    }
}
